//
//  UIScrollView+Placeholder.m
//  WCImApp
//
//  Created by alfie on 2019/11/6.
//  Copyright © 2019 WCImApp. All rights reserved.
//

#import "UIScrollView+Placeholder.h"
#import <objc/runtime.h>

@implementation UIScrollView (Placeholder)
static const char *MOScrollViewPlaceholderKey    = "MOScrollViewPlaceholderKey";

- (void)setPlaceholder:(MOScrollViewPlaceholder *)placeholder {
    objc_setAssociatedObject(self, MOScrollViewPlaceholderKey, placeholder, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}

- (MOScrollViewPlaceholder *)placeholder {
    MOScrollViewPlaceholder *_placeholder = objc_getAssociatedObject(self, MOScrollViewPlaceholderKey);
    if (!_placeholder) {

        _placeholder = [MOScrollViewPlaceholder new];
        _placeholder.scrollView = self;
        objc_setAssociatedObject(self, MOScrollViewPlaceholderKey, _placeholder, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
    }
    return _placeholder;
}

@end
